import { readFileSync } from 'fs';
import * as yaml from 'js-yaml';
import { join } from 'path';

export default () => {
  const envMap = {
    development: 'dev',
    test: 'test',
    production: 'prod',
  };

  const env = process.env.NODE_ENV;
  console.log('env:==>', env);

  return yaml.load(
    readFileSync(join(__dirname, `./${envMap[env] || 'prod'}.yml`), 'utf8'),
  ) as Record<string, any>;
};
